package com.gzh.custom.spring.boot.autoconfigure;

import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.StringUtils;

/**
 * @Description:
 * @package: com.gzh.custom.spring.boot.autoconfiguration
 * @Auther: Pf.Guo
 * @Date: Created in 2021/5/10 10:32
 */
@Configuration
@EnableConfigurationProperties(CustomProperties.class)
public class CustomAutoConfiguration {
    public static final String default_username = "admin";
    public static final String default_password = "123456";

    private CustomProperties properties;

    static {
        System.out.println("自定义starter启动……");
    }

    public CustomAutoConfiguration(CustomProperties properties) {
        if (StringUtils.isEmpty(properties.getUsername()))
            properties.setUsername(default_username);
        if (StringUtils.isEmpty(properties.getPassword()))
            properties.setPassword(default_password);
        this.properties = properties;
    }
}
